import React, {Component} from 'react';
import ReactDOM from 'react-dom';

function logger(OldComponent: any) {
  return class extends React.Component {
    start: number | undefined;

    componentWillMount(): void {
      this.start = Date.now()
    }

    componentDidMount(): void {
      console.log(`组件渲染一共花了${Date.now() - this.start!}ms`);
    }

    render() {
      return <OldComponent/>
    }
  }
}

class Hello extends React.Component {
  render() {
    return <div>hello</div>
  }
}

const X = logger(Hello);

ReactDOM.render(<X/>, document.getElementById('root'));

export {}
